<template>
    <view class="app-container balance">
        <z-paging ref="paging" v-model="list" @query="queryList">
            <template #top>
                <zzk-nav title="提现记录"></zzk-nav>
            </template>
            <view class="balance-list">
                <view class="balance-item" v-for="item in list" :key="item.id">
                    <view class="line flexrow top">
                        <text class="tag" :class="[item.status]">{{ status[item.status] }}</text>
                        <text class="txt b f">提现</text>
                        <text class="txt b">{{ convertFenToYuan(item.amount) }}</text>
                    </view>
                    <view class="line">
                        <text class="txt h">备注：{{ item.remark }}</text>
                    </view>
                    <view class="line" v-if="item.status === 'REJECTED'">
                        <text class="txt r">驳回理由：{{ item.approveRemark }}</text>
                    </view>
                    <view class="line flexrow">
                        <text class="txt">{{ item.created }}</text>
                    </view>
                </view>
            </view>
        </z-paging>
    </view>
</template>

<script setup>
import { ref } from 'vue'
import { withdrawList } from '@/api/merchant.js'
import { convertFenToYuan } from '@/utils/util'

const paging = ref(null)
const list = ref([])

const status = ref({
    'APPROVING': '审核中',
    'REJECTED': '已拒绝',
    'COMPLETED': '已完成'
})

const queryList = (page, size) => {
    const data = {
        page,
        size
    }
    withdrawList(data).then(res => {
        paging.value.complete(res.records)
    })
}
</script>

<style lang="scss" scoped>
.balance {
    &-list {
        border-radius: 8rpx;
        padding: 20rpx $zzk-margin 0;
    }
    &-item {
        padding: 24rpx;
        background-color: #fff;
        margin-bottom: 20rpx;
        border-radius: 8rpx;
        .line {
            align-items: center;
            &.top {
                margin-bottom: 8rpx;
            }
        }
        .txt {
            font-size: 28rpx;
            line-height: 48rpx;
            color: #999;
            &.b {
                font-weight: 700;
                color: #000;
            }
            &.f {
                flex: 1;
            }
            &.h {
                color: #000;
            }
            &.r {
                color: $u-error;
            }
        }
        .tag {
            font-size: 24rpx;
            line-height: 48rpx;
            padding: 0 8rpx;
            background-color: $u-info-light;
            color: $u-info;
            border-radius: 4rpx;
            margin-right: 16rpx;
            &.APPROVING {
                background-color: $u-primary-light;
                color: $u-primary;
            }
            &.COMPLETED {
                background-color: $u-success-light;
                color: $u-success;
            }
            &.REJECTED {
                background-color: $u-error-light;
                color: $u-error;
            }
        }
    }
}
</style>